package com.sdcx.agrobank.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.blankj.utilcode.util.SPUtils;
import com.bumptech.glide.Glide;
import com.sdcx.agrobank.R;
import com.sdcx.agrobank.base.BaseFragment;
import com.sdcx.agrobank.bean.SPBean;
import com.sdcx.agrobank.ui.activity.Main3Activity;
import com.sdcx.agrobank.ui.activity.MingxiActivity;
import com.sdcx.agrobank.ui.activity.ZHActivity;
import com.sdcx.agrobank.util.GlideUtil;
import com.stx.xhb.androidx.XBanner;

import java.util.ArrayList;

/**
 * Project   : haveyou
 * Package    : com.sdcx.agrobank.ui.fragment
 *
 * @author : Galaxy
 * @date : 2020/11/24 10:28
 * Desc      : TODO
 **/
public class mainFragment extends BaseFragment {

    private XBanner banner;
    private ArrayList<Object> arr;
    private LinearLayout wodezhanghu,wodezhanghu2,mingxi,mingxi2;
    private String login;

    @Override
    public void onLazyLoad() {

    }

    @Override
    protected int initLayout() {
        return R.layout.mainfragment;
    }

    @Override
    protected void init(View view) {

        banner = view.findViewById(R.id.banner);
        wodezhanghu = view.findViewById(R.id.wodezhanghu);
        wodezhanghu2 = view.findViewById(R.id.wodezhanghu2);
        wodezhanghu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                login = SPBean.open;
                if (login.equals("1")) {
                    startActivity(new Intent(getContext(), ZHActivity.class));
                }else {
                    startActivity(new Intent(getContext(), Main3Activity.class));
                }
            }
        });
        wodezhanghu2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                login = SPBean.open;
                if (login.equals("1")) {
                    startActivity(new Intent(getContext(), ZHActivity.class));
                }else {
                    startActivity(new Intent(getContext(), Main3Activity.class));
                }
            }
        });
        mingxi = view.findViewById(R.id.mingxi);
        mingxi2 = view.findViewById(R.id.mingxi2);
        mingxi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                login = SPBean.open;
                if (login.equals("1")) {
                    startActivity(new Intent(getContext(), MingxiActivity.class));
                }else {
                    startActivity(new Intent(getContext(), Main3Activity.class));
                }
            }
        });
        mingxi2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                login = SPBean.open;
                if (login.equals("1")) {
                    startActivity(new Intent(getContext(), MingxiActivity.class));
                }else {
                    startActivity(new Intent(getContext(), Main3Activity.class));
                }
            }
        });
        arr = new ArrayList<>();
        arr.add(R.mipmap.banner);
        arr.add(R.mipmap.banner);
        arr.add(R.mipmap.banner);

        banner.setmAdapter(new XBanner.XBannerAdapter() {
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                //GlideUtil.display(getContext(),arr.get(position),(ImageView) view);
                Glide.with(getContext()).load(arr.get(position)).into((ImageView) view);
            }
        });
        banner.setData(arr,null);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initLogic() {

    }

    @Override
    public void initImmersionBar() {

    }

    @Override
    public boolean immersionBarEnabled() {
        return false;
    }
}
